/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf;

import com.openbrew.openbrewrf.views.POSSupplyView;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "RecipeAdditives")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RecipeAdditives.findAll", query = "SELECT r FROM RecipeAdditives r"),
    @NamedQuery(name = "RecipeAdditives.findByAdditiveID", query = "SELECT r FROM RecipeAdditives r WHERE r.additiveID = :additiveID"),
    @NamedQuery(name = "RecipeAdditives.findByAdditiveLbs", query = "SELECT r FROM RecipeAdditives r WHERE r.additiveLbs = :additiveLbs"),
    @NamedQuery(name = "RecipeAdditives.findByAdditiveUnits", query = "SELECT r FROM RecipeAdditives r WHERE r.additiveUnits = :additiveUnits"),
    @NamedQuery(name = "RecipeAdditives.findByAdditiveNotes", query = "SELECT r FROM RecipeAdditives r WHERE r.additiveNotes = :additiveNotes")})
public class RecipeAdditives implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "additiveID")
    private Integer additiveID;
    @Basic(optional = false)
    @NotNull
    @Column(name = "additiveLbs")
    private float additiveLbs;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 10)
    @Column(name = "additiveUnits")
    private String additiveUnits;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 100)
    @Column(name = "additiveNotes")
    private String additiveNotes;
    @JoinColumn(name = "supplyID", referencedColumnName = "SupID", nullable=true)
    @ManyToOne(optional = true)
    private POSSupplyView supply;

    public RecipeAdditives() {
    }

    public RecipeAdditives(Integer additiveID) {
        this.additiveID = additiveID;
    }

    public RecipeAdditives(Integer additiveID, float additiveLbs, String additiveUnits, String additiveNotes) {
        this.additiveID = additiveID;
        this.additiveLbs = additiveLbs;
        this.additiveUnits = additiveUnits;
        this.additiveNotes = additiveNotes;
    }

    public Integer getAdditiveID() {
        return additiveID;
    }

    public void setAdditiveID(Integer additiveID) {
        this.additiveID = additiveID;
    }

    public float getAdditiveLbs() {
        return additiveLbs;
    }

    public void setAdditiveLbs(float additiveLbs) {
        this.additiveLbs = additiveLbs;
    }

    public String getAdditiveUnits() {
        return additiveUnits;
    }

    public void setAdditiveUnits(String additiveUnits) {
        this.additiveUnits = additiveUnits;
    }

    public String getAdditiveNotes() {
        return additiveNotes;
    }

    public void setAdditiveNotes(String additiveNotes) {
        this.additiveNotes = additiveNotes;
    }

    public POSSupplyView getSupply() {
        return supply;
    }

    public void setSupply(POSSupplyView supply) {
        this.supply = supply;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (additiveID != null ? additiveID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RecipeAdditives)) {
            return false;
        }
        RecipeAdditives other = (RecipeAdditives) object;
        if ((this.additiveID == null && other.additiveID != null) || (this.additiveID != null && !this.additiveID.equals(other.additiveID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.RecipeAdditives[ additiveID=" + additiveID + " ]";
    }
    
}
